<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@page import="portal.vo.*" %>
<%@page import="java.util.*" %> 

<script>

function detalleProducto(selurl) {

    var left       = 50;
    var top        = 50;
    var height     = 500;
    var width      = 400;
    var scrollbars = 'yes';
  
    selector = window.open (selurl, "Selector", "toolbar=no,directories=no,scrollbars=" + scrollbars + ",menubar=yes,status=yes,resizable=no,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top);  
    }

</script>

<%
List<ItemVO> items = new ArrayList<ItemVO>();
if(request.getAttribute("listaCarrito") != null) 
	items = (List<ItemVO>)request.getAttribute("listaCarrito");

%>

<form action="/PortalWeb/EliminarDeCarritoServlet" method="post">
<a name="inicio"></a>
<table class="listaCarritoContenedor" cellSpacing=1 cellPadding=3 align="center" border=0>
	<tbody>
		<tr>
			<td class=titulotabla align="center" width="16%">Imagen</td>
			<td class=titulotabla align="center" width="16%">Nombre</td>
			<td class="titulotabla" align="center" width="16%">Categoria</td>
			<td class=titulotabla align="center" width="16%">Marca</td>
			<td class="titulotabla" align="center" width="16%">Precio</td>
			<td class=titulotabla align="center" width="16%">Cantidad</td>
			<td class=titulotabla align="center" width="16%">&nbsp;</td> <!-- detalle -->
			<td class=titulotabla align="center" width="16%">&nbsp;</td> <!-- borrar -->
		</tr>
		<%int i = 0; %>
		<%for(ItemVO it: items) { %>
		<% i++; %>
		 <%
              if ((i % 2) == 0) {
                out.println("<TR align=\"center\" class=\"odd\">");
              } else {
                out.println("<TR align=\"center\" class=\"even\">");
              }
            %>
			<td class=azul align="center"><IMG alt="foto" src=<%=it.getItemProducto().getImagen() %> border="0" /></td>
			<td class=azul align="center"><%= it.getItemProducto().getNombre() %></td>
			<td class=azul align="center"><%= it.getItemProducto().getCategoria() %></td>
			<td class=azul align="center"><%= it.getItemProducto().getMarca() %></td>
			<td class=azul align="right">$ <%= it.getItemProducto().getPrecio() %></td>
			<td class=azul align="right">
			  <span class="ajax" onClick="requestContentCarrito('/PortalWeb/AgregarACarritoServlet?id=<%= it.getItemProducto().getId() %>');$(this).next().next().html(parseInt($(this).next().next().html())+1)"><b>+</b></span>
		      /
		      <span class="ajax" onClick="requestContentCarrito('/PortalWeb/EliminarEnUnoDeCarritoServlet?id=<%= it.getItemProducto().getId() %>');if(parseInt($(this).next().html())==1){$(this).parent().parent().fadeOut('slow');}else{$(this).next().html(parseInt($(this).next().html())-1);}"><b>-</b></span> 
			  &nbsp;
			  <span><%= it.getCantidad() %></span>
			
			</td>
			<td class=azul align="center"><a href="#" onclick="javascript:detalleProducto('/PortalWeb/ObtenerDetalleServlet?id=<%= it.getItemProducto().getId() %>')">Ver detalle</a></td>
			<td class=azul align="center"><a href="#" onclick="requestContentCarrito('/PortalWeb/EliminarDeCarritoServlet?id=<%= it.getItemProducto().getId() %>');$(this).parent().parent().fadeOut('slow')">Eliminar</a></td>
		<%
              out.println("</TR>");
            %>
		<%} %>
	 	<tr bgColor=#cccccc>
	  	    <TD>&nbsp;</TD>
	        <TD>&nbsp;</TD>	      
	  	    <TD>&nbsp;</TD>
	  	    <TD>&nbsp;</TD>
	  	    <TD>&nbsp;</TD>
	  	    <TD>&nbsp;</TD>
	  	    <TD>&nbsp;</TD>
	  	    <TD>&nbsp;</TD>
        </tr>

	</tbody>
</table>

</form>